Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Scripting Additions Guide /
Chapter 2 - Scripting Addition Commands / Command Definitions
/


New File

The New File command displays a dialog box like the one in Figure 2-6 to allow the user to specify a filename and a location. New File does not create a new file; rather, it returns a reference to a file with the name and location specified by the user. You can store the reference in a variable and pass it to Open for Access (which in turn creates the file in the specified location) or to any other command for which you want to specify a file that doesn't yet exist.

New File is the only command provided by the New File scripting addition.

Figure 2-6 A New File dialog box

SYNTAX
new file [ with prompt promptString ] [ default name defaultName ]
PARAMETERS
promptString
The prompt that appears in the dialog box. The string you specify can be up to 255 characters long. If you omit the
with prompt parameter, the prompt "New File Name"
is displayed.
Class: String
Default Value: "New File Name"

defaultName
The default filename that appears in the dialog box. The string you specify can be up to 255 characters long. If you omit the default name parameter, no default filename is displayed.
Class: String
Default Value: (no default name)
RESULT
A reference of the form file "Disk:Folder1:Folder2:...:Filename" for the filename and location specified by the user.

EXAMPLES
set x to new file
open for access x
NOTES
If the user chooses the Cancel button, New File returns error -128. If you
want your script to continue after the user clicks Cancel, you must include
an error handler. For information about Tell statements and error handlers,
see Chapter 8, "Handlers," of the AppleScript Language Guide.

ERRORS
Error
number
Error message
-108Out of memory.
-128User canceled.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
18 DEC 1996